<?php /*
	
*/ ?>
<?php 
include("inc/head.inc.php");
$globaltot=0;
if(isset($_REQUEST['proid']) && ($_REQUEST['proid'])!="")
	  {
	  	$seid=mysql_real_escape_string($_REQUEST['proid']);
		$productid=mysql_real_escape_string($_REQUEST['proid']);
	  }
	 
if(isset($_REQUEST['a']) && ($_REQUEST['a'])=="3")
		{
			if(isset($_REQUEST['intid']) && ($_REQUEST['intid']))
			{
				$id=mysql_real_escape_string($_REQUEST['intid']);
				$sql=mysql_query("delete from tblcustomerbaskets where intid='$id'");
				$sql2=mysql_query("delete from tblcustmerbasketattributes where intcustomerbasketid='$id'");
				$updatemsg = "Item has been deleted from your basket";
			}
		}

if(isset($_GET['a']) && ($_GET['a'])=="99")
		{
			if(isset($_REQUEST['proid']) && ($_REQUEST['proid']))
			{	
				$id=mysql_real_escape_string($_REQUEST['intid']);
				$newquant=mysql_real_escape_string($_REQUEST['qty_'.$_REQUEST['proid']]);
				$sql=mysql_query("update tblcustomerbaskets set intproductquantity=$newquant where intid=$id");
				$updatemsg = "Your basket has been updated";	
			}
}
?>
<body>
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  
  <tr>
    <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td valign="top"class="leftmenuback"><?php include(INC."left.inc.php") ?></td>
        <td valign="top">
	
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="23" class="head">
            <div class="pageheader">Your shopping cart</div>
		  </td>
        </tr>
		<tr>
          <td  align="center" class="msg" height="20px;"><?php 
  if(isset($updatemsg)) {
  	echo "<span align=\"center\" class=\"msg\">$updatemsg</span>";
  }
  ?></td>
        </tr>
        <tr>
          <td>
		 
		  <table width="98%" height="200" border="0" align="left" cellpadding="2" cellspacing="0" class="prborderbg" style="margin-left:5px;">
              <tr align="center" class="catnamerep">
                <td width="8%" bgcolor="#000000" class="style1">Remove</td>
                <td width="8%" bgcolor="#000000" class="style1">Edit</td>
                <td width="20%" height="23" bgcolor="#000000" class="style1">Product</td>
                <td width="39%" bgcolor="#000000" class="style1">Details</td>
                <td width="8%" bgcolor="#000000" class="style1">Qty</td>
                <td width="15%" bgcolor="#000000" class="style1">Sub Total</td>
              </tr>
              <?php
	  if(isset($_SESSION['memberid']) && ($_SESSION['memberid'])!="")  {
	 	$memid=$_SESSION['memberid'];
	  	$sql1="select * from tblcustomerbaskets where intcustomerid='$memid'";
	  } else {
	  	$sid=session_id();
	  	$sql1="select * from tblcustomerbaskets where varsessionid='$sid'";
	  }	
		$resbask=$n02586916_db->select($sql1);
		if(count($resbask)>0)
		{
			$sum=0;
			for($i=0;$i<count($resbask);$i++)
			{
				$prtid=$resbask[$i]['intproductid'];
				$basketid=$resbask[$i]['intid'];			
	  ?>
	  		<form name="cart" action="cart.php?a=99&intid=<?php echo $resbask[$i]['intid'];?>" method="post">
              <tr align="center">
                <td class="font" style="border-bottom:1px solid #000000;"><a href="cart.php?a=3&intid=<?php echo $resbask[$i]['intid'];?>" onClick="return confirm('Are you sure you want to remove this product from your cart');"><img src="images/delete.bmp"  border="0"/></a></td>
                <td class="font_w"  style="border-bottom:1px solid #000000;"><?php 
				if(count($resbask)>0)
				{ ?>
				<input type="image" src="images/edit.bmp" name="editbutton" value="Edit" />
				<?php }?></td>
                <td class="font"  style="border-bottom:1px solid #000000;">
				<?php $sql="select * from tblproducts where intprodid='$prtid'";
					$respr=$n02586916_db->select($sql);
					if(count($respr)>0)
					{
						$qty=$respr[0]['intprodquantity'];
						if (file_exists("images/product/midium/".$respr[0]['intproddefaultimg'])) { 
							$image="images/product/midium/".$respr[0]['intproddefaultimg'];
							$largeimage="images/product/big/".$respr[0]['intproddefaultimg'];
						} else { 
							$image="images/product/midium/noimage.jpg";
							$largeimage="images/product/big/noimage.jpg";
						}	 
							?>
							<img src="<?php echo $image;?>" width="50" height="50"  onClick="window.open('<?php echo $largeimage;?>');" style="cursor:hand" vspace="1"/>
							<?php 
							$sql9="select * from tblproddesc where intid='$prtid'";
							$resimg=$n02586916_db->select($sql9);
							if($resimg){echo "<br /><strong>".stripslashes($resimg[0]['varprodname'])."</strong>"; }
					}?></td>
						<td align="left" class="font" style="border-bottom:1px solid #000000;">
							Selected Product Options:
							<ul style="margin-left: 0; padding-left: 0;">
							<?php 
								$optionssql="SELECT * FROM tblcustmerbasketattributes WHERE intcustomerbasketid=$basketid";
								$optionsresult=$n02586916_db->select($optionssql);
								if ($optionsresult) { 
									for ($b=0;$b<count($optionsresult);$b++) {
										$attributesql = "SELECT tblproductattributes.*, tbloptionvalues.varoptionvaluename, tblproductoptions.varoptionname FROM tblproductattributes INNER JOIN tblproductoptions ON tblproductattributes.intoptionvalueid=tblproductoptions.intid INNER JOIN tbloptionvalues ON tblproductattributes.intoptionid=tbloptionvalues.intid  WHERE intattributeid=".$optionsresult[$b]['intproductoptionid'];
										$attributeresult=$n02586916_db->select($attributesql);
										echo "<li><strong>".stripslashes($attributeresult[0]['varoptionvaluename']).":</strong> ".stripslashes($attributeresult[0]['varoptionname'])."</li>";
									}
								} else { 
									echo "No options available";
								}
							?>
							</ul>
							</td>
						<td class="font"  style="border-bottom:1px solid #000000;">
						<input name="qty_<?php echo $prtid;?>" type="text" class="feature_headingbg"  value="<?php echo stripslashes($resbask[$i]['intproductquantity']);?>" size="3" /> 
						<input type="hidden" name="proid" value="<?php echo $prtid;?>" />
						</td>
						<td class="price"  style="border-bottom:1px solid #000000;"><?php 
				$price= $resbask[$i]['dectotalprice'];
				$quanty=$resbask[$i]['intproductquantity'];
				$total=$price*$quanty;
				?>&pound;<?php echo number_format(round($total,2), 2, '.', '');
				$globaltot = $globaltot+$total;
				?></td>
                </tr>
              	</form>
              <?php
	  			}} else { 
					echo '<tr><td colspan="6" align="center" class="font"><span align="center" class="msg">Your Cart is Empty</span></td></tr>';
				}?>
              <tr>
                <td colspan="4" align="center" class="font">&nbsp;</td>
				<td class="style2">Total:</td>
				<td align="center" class="price">&pound;<?php echo number_format($globaltot, 2, '.', '');?></td>
              </tr>
              <tr>
                <td height="1" colspan="6" align="center" class="font">&nbsp;</td>
              </tr>
              <tr valign="middle" class="bordertop">
                <td colspan="3" align="right" class="font"><a href="products.php" class="ab"><img src="images/continue.gif" width="91" height="22" border="0" /></a></td>
                <td colspan="2" align="center" class="font">
				
				<?php
				if(count($resbask)>0)
				{ 
					if(!isset($_SESSION['memberid']))
					{
					?>
							<a href="customerlogin.php?a=6" class="continue"><div style="background-image:url(images/backimg.gif); background-repeat:no-repeat; width:91px; height:22px; padding-top:3px;" align="center">Checkout</div></a>
				<?php }	else {?>
                    <a href="checkpersonaldetail.php" class="continue"><div style="background-image:url(images/backimg.gif); background-repeat:no-repeat; width:91px; height:22px; padding-top:3px;" align="center">Checkout</div></a>
                    <?php }
				}?> </td>
              </tr>
            </table>
		
        </td>
        </tr> 
      </table>
	  <br />
	  <table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <?php 
	  $sqlbann="select * from tblbanners";
	  $resbann=$n02586916_db->select($sqlbann);
	  if($resbann) {
	  	$bannercount= count($resbann);
	  }
	  $raqndomcount=rand(0,$bannercount-1);
	  $sqlbanner="select * from tblbanners where intstatus='1' limit ".$raqndomcount.",1";
	  $resbanner=$n02586916_db->select($sqlbanner);
	  ?>
	  <tr>
		<td align="center">
		<?php
		if($resbanner)
	  	{
		?>
		<a href="<?php echo stripslashes($resbanner[0]['varbannerurl']);?>" target="_blank"><img src="images/banner/<?php echo stripslashes($resbanner[0]['varbannerimage']);?>" hspace="0" vspace="0" border="0"/></a>
		<?php }?>
		</td>
	  </tr>
	</table>

    </td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>
